package dao

import (
	"code.byted.org/mars/golang_week2/Error"
	"github.com/pkg/errors"
)

type People struct {
	ID   int64
	Name string
	Age  int64
}

func GetPeople(ID int64) (*People, error) {
	var p People
	sql := "select * from people where id = ?" // ignore_security_alert
	row := Db.QueryRow(sql, ID)
	err := row.Scan(&p.ID, &p.Name, &p.Age)
	if err != nil {
		return nil, errors.Wrapf(Error.RecordNotFound, "sql: %s, err: %v", sql, err)
	}
	return &p, nil
}
